package com.game.base;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Observable;

public class SimulationObject extends Observable implements Serializable {
	
	private static final long serialVersionUID = 1L;

	public static final int ROOT = 1;
	public int id;
	public int pid;
	public ArrayList<Integer> children;
	private boolean dirty;
	public void setDirty(boolean value){
		this.dirty = value;
		if(value)
			this.setChanged();
	}
	public boolean isDirty(){
		return this.dirty;
	}
	public SimulationObject() {
		children = new ArrayList<Integer>();
	}
	public String toString(){
		if(this.getClass().equals(SimulationObject.class))
			return "[SimulationObj(id="+this.id+",pid="+this.pid+",children="+this.children+")]";
		else
			return "["+this.getClass().getSimpleName()+" extends SimulationObj(id="+this.id+",pid="+this.pid+",children="+this.children+")]";
	}
	@Override
	protected void finalize() throws Throwable {
		this.deleteObservers();
		super.finalize();
	}
}
